home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / examples / misc / wexmast / wdroplist.pro < prev    next >
Text File  |  1997-07-08  |  2KB  |  87 lines

  1. ; $Id: wdroplist.pro,v 1.4 1997/01/15 04:29:15 ali Exp $
  2. ;
  3. ;
  4. ; Copyright (c) 1993-1997, Research Systems, Inc.  All rights reserved.
  5. ;       Unauthorized reproduction prohibited.
  6.  
  7. ; This is the code for a simple droplist widget.
  8. ; In this example, a droplist is created that has
  9. ; a list of eleven items, numbered zero through ten,
  10. ; that can be selected by clicking on the droplist
  11. ; button.  When a list item is selected, that item's
  12. ; name is printed in the IDL window and the droplist
  13. ; button's label changes to reflect the new selection.
  14.  
  15. PRO wdroplist_event, event
  16. ; This procedure is the event handler for a simple droplist widget.
  17.  
  18. ; Put the User Value of any widget touched into the variable 'eventval':
  19.  
  20. WIDGET_CONTROL, event.id, GET_UVALUE = eventval
  21.  
  22. ; This CASE statement branches based upon the value of 'eventval':
  23.  
  24. CASE eventval OF
  25.     "LIST"    : BEGIN
  26.           ; The list has been touched.
  27.           ; The index of the list item touched is held in
  28.           ; 'event.index'... how convenient!
  29.  
  30.           ; Put the value of 'event.index' into the variable
  31.           ; 'selection':
  32.           selection = event.index
  33.  
  34.           ; Print the index of the item selected in the
  35.           ; IDL window:
  36.           PRINT, 'List item ' + STRING(selection) + ' selected.'
  37.           END
  38. ENDCASE
  39. END
  40.  
  41.  
  42. PRO wdroplist, GROUP = GROUP
  43. ; This procedure creates a simple droplist widget.
  44.  
  45. ; Make the top-level base. The XSIZE keyword is used to make
  46. ; the base wide enough so that the full title shows:
  47.  
  48. base = WIDGET_BASE(TITLE = 'Example Droplist Widget', /COLUMN, XSIZE = 300)
  49.  
  50. ; Make an array that holds the text of the list items:
  51.  
  52. listitems = [    'Item Zero', $
  53.         'Item One', $
  54.         'Item Two', $
  55.         'Item Three', $
  56.         'Item Four', $
  57.         'Item Five', $
  58.         'Item Six', $
  59.         'Item Seven', $
  60.         'Item Eight', $
  61.         'Item Nine', $
  62.         'Item Ten']
  63.  
  64. ; Make the droplist widget. The YSIZE keyword controls how many list items
  65. ; will be visible at a time:
  66.  
  67. list = WIDGET_DROPLIST(base, $        ; This list belongs to 'base'.
  68.            VALUE = listitems, $    ; Put 'listitems' in the list.
  69.            UVALUE = 'LIST', $    ; 'LIST' is this widgets User Value.
  70.            XSIZE=200, $
  71.            YSIZE = 50)        ; Show five items at a time.
  72.  
  73. ; Realize the widgets:
  74. WIDGET_CONTROL, base, /REALIZE
  75.  
  76. ; Hand off to the XMANAGER:
  77. XMANAGER, 'wdroplist', base, GROUP_LEADER = GROUP, /NO_BLOCK
  78.  
  79. END
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.